package com.learning.security.dal.dataobject;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * OAuth2 访问令牌
 * </p>
 *
 * @author xxx
 * @since 2024-10-03
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("system_oauth2_access_token")
@Schema(name = "Oauth2AccessTokenDO", description = "OAuth2 访问令牌")
public class AdminOAuth2AccessTokenDO extends TenantBaseDO {

    private static final long serialVersionUID = 1L;

    @Schema(description = "编号")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Schema(description = "用户编号")
    @TableField("user_id")
    private Long userId;

    @Schema(description = "用户类型")
    @TableField("user_type")
    private Integer userType;

    @Schema(description = "用户信息")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String, String> userInfo;

    @Schema(description = "访问令牌")
    @TableField("access_token")
    private String accessToken;

    @Schema(description = "刷新令牌")
    @TableField("refresh_token")
    private String refreshToken;

    @Schema(description = "客户端编号")
    @TableField("client_id")
    private String clientId;

    @Schema(description = "授权范围")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> scopes;

    @Schema(description = "过期时间")
    @TableField("expires_time")
    private LocalDateTime expiresTime;

}
